package com.zmn.oms.admin.controller.report.coupanalyse;

import com.zmn.common.dto2.ResponseDTO;
import com.zmn.dms.common.dto.coup.coupbatchstatistics.dio.CoupBatchStatisticsActivityCoupBatchDIO;
import com.zmn.dms.common.dto.coup.coupbatchstatistics.dro.CoupBatchStatisticsActivityCoupBatchDRO;
import com.zmn.dms.common.dto.coup.coupbatchstatistics.dro.CoupBatchStatisticsActivityDRO;
import com.zmn.dms.dubbo.interfaces.coup.CoupBatchStatisticsRemoteService;
import com.zmn.oms.admin.controller.OmsBaseController;
import org.apache.dubbo.config.annotation.Reference;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 优惠卷分析报表basecontroller
 * @author: HuangYongJie
 * @version: v1.0
 * @since: 2019/11/5 19:22
 **/
public class ReportCoupAnalyseBaseController extends OmsBaseController {

    @Reference(version = com.zmn.dms.dubbo.utils.DubboConsts.INTERFACE_VERSION, check = false)
    CoupBatchStatisticsRemoteService coupBatchStatisticsRemoteService;

    /**
     * 获取所有的活动
     * @return
     */
    protected List<CoupBatchStatisticsActivityDRO> findActivityList() {
        ResponseDTO<List<CoupBatchStatisticsActivityDRO>> responseDTO = coupBatchStatisticsRemoteService.getAllActivity();
        return responseDTO.getData();
    }

    /**
     * 根据活动id查询批次
     * @param activityId
     * @return
     */
    protected List<Integer> listBatchIdByActivity(Integer activityId){
        CoupBatchStatisticsActivityCoupBatchDIO dio = new CoupBatchStatisticsActivityCoupBatchDIO();
        dio.setActivityId(activityId);
        ResponseDTO<List<CoupBatchStatisticsActivityCoupBatchDRO>> responseDTO = coupBatchStatisticsRemoteService.getActivityCoupBatch(dio);
        List<CoupBatchStatisticsActivityCoupBatchDRO> dataList = responseDTO.getData();
        return dataList.stream().map(obj->obj.getBatchId()).collect(Collectors.toList());
    }
}
